<template>
  <div>
    <el-row ref="search_form">
          <el-col :span="24">
            <div class="search-box">
              <el-form :inline="true" size="medium" :model="searchForm">


                <el-form-item label="">
                  <el-select v-model="searchForm.carEnterpriseId" size="mini" placeholder="请选择车企" clearable>
                    <el-option v-for="item in carEntList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="">
                  <el-select v-model="searchForm.carTypeId" size="mini" placeholder="请选择车型类别" clearable>
                    <el-option v-for="item in carTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="">
                  <el-select v-model="searchForm.productTypeIds" size="mini" placeholder="请选择申报类型" clearable>
                    <el-option v-for="item in testProductTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="">
                  <el-select v-model="searchForm.customerName" size="mini" placeholder="请选择业务经理" clearable>
                    <el-option v-for="item in customerNameList" :key="item.id" :label="item.name" :value="item.name"></el-option>
                  </el-select>
                </el-form-item>





                <el-form-item>
                  <el-button  size="mini" type="primary" @click="search">查询</el-button>
                </el-form-item>
                <el-form-item>
                  <el-button  size="mini" type="primary" @click="clear">清空</el-button>
                </el-form-item>
                <el-form-item>
                  <el-button  size="mini" type="primary" @click="search">刷新</el-button>
                </el-form-item>
                <el-form-item>
                  <el-button type="primary" @click="showAddDialogForm" size="mini">新增</el-button>
                </el-form-item>


              </el-form>
            </div>
          </el-col>
        </el-row>









    <el-table
      :data="tableData"
      :header-cell-style="{backgroundColor:'#f4f4f5',textAlign:'center'}"
      :cell-style="{textAlign:'center'}"
      :height="tableHeight"
      border
      style="width: 100%">
      <el-table-column
        prop="id"
        label="序号"
        type="index"
        width="80">
      </el-table-column>
      <el-table-column
        prop="carEnterpriseName"
        label="车企"
        min-width="120">
      </el-table-column>
      <!-- <el-table-column
        prop="brand"
        label="车企商标"
        min-width="120">
      </el-table-column> -->
      <el-table-column
        prop="customerName"
        label="业务经理"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="name"
        label="产品名称"
        min-width="120">
        <!-- <template scope="scope">

          {{nameModel(scope.row.name,scope.row.model)}}
        </template> -->
      </el-table-column>
      <el-table-column
        prop="model"
        label="产品型号"
        min-width="120">
        <!-- <template scope="scope">

          {{nameModel(scope.row.name,scope.row.model)}}
        </template> -->
      </el-table-column>

      <el-table-column
        prop="productTypeName"
        label="申报类型"
        min-width="150">
        <template scope="scope">
          {{scope.row.productTypeName1+"/"+scope.row.productTypeName2}}
        </template>
      </el-table-column>
      <el-table-column
        prop="serialNumber"
        label="检测项目统计"
        min-width="120">
        <template scope="scope">
          {{serialNumber(scope.row.serialNumber,scope.row.itemNum,scope.row.itemList)}}
        </template>
      </el-table-column>

      <el-table-column
        prop="suggestTime"
        label="建议完成时间"
        min-width="120">
        <template scope="scope">
          {{fmtDate(scope.row.suggestTime)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="importance"
        label="是否重要车型"
        min-width="120">
        <template scope="scope">
          {{significance(scope.row.importance)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="cause"
        label="原因"
        min-width="120">
      </el-table-column>
      <!-- <el-table-column
        prop="orgName"
        label="检测机构"
        min-width="120">
      </el-table-column> -->

      <!-- <el-table-column
        prop="productTypeName"
        label="产品类型"
        min-width="150">
        <template scope="scope">
          {{scope.row.productTypeName+"/"+scope.row.parentProductTypeName}}
          <template v-if="scope.row.hasDx">+定型</template>
        </template>
      </el-table-column> -->

      <!-- <el-table-column
        prop="testItems"
        label="检测项目"
        min-width="170">
        <template scope="scope">
          <span v-html="parseTestItem2(scope.row)"></span>
        </template>
      </el-table-column> -->

      <!-- <el-table-column
        prop="rebate"
        label="默认折扣"
        min-width="120">
        <template scope="scope">
          {{scope.row.rebate}}%
        </template>
      </el-table-column>
      <el-table-column
        prop="siteRebate"
        label="默认场地折扣"
        min-width="120">
        <template scope="scope">
          {{scope.row.siteRebate}}%
        </template>
      </el-table-column>
      <el-table-column
        prop="priceCost"
        label="成本总价"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="price"
        label="总价"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="payPrice"
        label="最终价"
        min-width="120">
      </el-table-column>
      <el-table-column
        prop="amount"
        label="其他费用"
        min-width="120">
      </el-table-column> -->
      <!-- <el-table-column
        prop="nickname"
        label="项目经理"
        min-width="120">
      </el-table-column> -->

      <!-- <el-table-column
        prop="isSend"
        label="是否送样"
        min-width="100">
        <template scope="scope">
          {{scope.row.isSend?"是":"否"}}
        </template>
      </el-table-column> -->


      <!-- <el-table-column
        prop="id"
        label="任务状态"
        min-width="120">
        <template scope="scope">
          <span v-if="scope.row.step == 0">未下发</span>
          <span v-if="scope.row.step == 1">已完成</span>
          <span v-if="scope.row.step == 2">工程师A</span>
          <span v-if="scope.row.step == 3">工程师B</span>
          <span v-if="scope.row.step == 4">工程师C</span>
          <span v-if="scope.row.stepStatus == 3">(回退)</span>
          <span v-if="scope.row.stepStatus == 4">(转交)</span>
        </template>
      </el-table-column> -->

      <el-table-column
        prop="updateTime"
        label="最后修改时间"
        min-width="160">
        <template scope="scope">
          {{fmtDate(scope.row.updateTime)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间"
        min-width="160">
        <template scope="scope">
          {{fmtDate(scope.row.createTime)}}
        </template>
      </el-table-column>
      <el-table-column
        prop="nickname"

        label="创建人"
        min-width="160">
      </el-table-column>

      <el-table-column
        prop="note"
        fixed="right"
        label="备注"
        min-width="160">
      </el-table-column>
      <el-table-column v-if="this.userRole != 7"
        prop="address"
        fixed="right"
        label="操作"
        min-width="250">
        <template slot-scope="scope" >
          <el-button size="mini" type="primary" @click="handlePriceOtherManage(scope.$index, scope.row)">其他费用管理</el-button>

          <el-button style="margin-top:8px" size="mini" type="primary" @click="handleOrderEdit(scope.$index, scope.row)">修改</el-button>

          <template >
          <el-button style="margin-top:8px" size="mini" type="primary" @click="handleOrderTaskNext(scope.$index, scope.row)">任务下发</el-button>
          </template>
          <el-button style="margin-top:8px" size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          <!-- <template v-if="scope.row.step == 0">
            <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
          <template v-if="scope.row.step == 1||scope.row.step == 2||scope.row.step == 3||scope.row.step == 4">
            <el-button size="mini" type="primary" @click="handleShowData(scope.$index, scope.row)">数据</el-button>
          </template>
          <template v-if="scope.row.step == 2||scope.row.step == 3||scope.row.step == 4">
            <el-button size="mini" type="primary" @click="handleToUser(scope.$index, scope.row)">转交</el-button>
          </template> -->
        </template>
      </el-table-column>
      <el-table-column v-if="this.userRole == 7"
        prop="address"
        fixed="right"
        label="操作"
        min-width="250">
        <template slot-scope="scope" >
          <!-- <el-button size="mini" type="primary" @click="handlePriceOtherManage(scope.$index, scope.row)">其他费用管理</el-button> -->
          <template v-if="scope.row.submit == 0">
          <el-button style="margin-top:8px" size="mini" type="primary" @click="handleOrderEdit(scope.$index, scope.row)">修改</el-button>

          <el-button style="margin-top:8px" size="mini" type="primary" @click="submitOrder(scope.$index, scope.row)">提交</el-button>
          </template>
          <!-- <template >
          <el-button style="margin-top:8px" size="mini" type="primary" @click="handleOrderTaskNext(scope.$index, scope.row)">任务下发</el-button>
          </template> -->
          <!-- <template v-if="scope.row.step == 0">
            <el-button size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">修改</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
          <template v-if="scope.row.step == 1||scope.row.step == 2||scope.row.step == 3||scope.row.step == 4">
            <el-button size="mini" type="primary" @click="handleShowData(scope.$index, scope.row)">数据</el-button>
          </template>
          <template v-if="scope.row.step == 2||scope.row.step == 3||scope.row.step == 4">
            <el-button size="mini" type="primary" @click="handleToUser(scope.$index, scope.row)">转交</el-button>
          </template> -->
        </template>
      </el-table-column>
    </el-table>
    <div class="block">
       <span class="demonstration"></span>
       <el-pagination
         @size-change="handleSizeChange"
         @current-change="handleCurrentChange"
         :current-page="currentPage"
         :page-sizes="[10, 20, 50, 100,200]"
         :page-size="pageSize"
         layout="total, sizes, prev, pager, next, jumper"
         :total="total">
       </el-pagination>
     </div>

    <el-dialog :title="editForm.id==0?'新增':'修改'" :visible.sync="editFormVisible" width="80%" top="5vh" :close-on-click-modal="false">
      <el-form :model="editForm" ref="editForm" :rules="editRules">
        <el-row>
          <el-col :span="12">
            <el-form-item label="车企" label-width="100px" prop="carEnterpriseId">
              <el-select v-model="editForm.carEnterpriseId" filterable placeholder="请选择" style="width: 100%;" :disabled="carEntDisabled" @change="onCarEntChange()">
                <el-option
                  v-for="item in carEntList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
              <!-- <el-button type="primary" icon="el-icon-refresh" circle style="margin-left: 10px;" @click="refreshCarEntList"></el-button>
              <el-button type="primary" icon="el-icon-edit" circle style="margin-left: 10px;" @click="handlerOpenPage(1)"></el-button> -->
            </el-form-item>
          </el-col>
          <el-col :span="12">
          <el-form-item label="商标" label-width="100px" prop="brand">
            <el-input v-model="editForm.brand" controls-position="right" :min="0" style="width: 100%;" disabled></el-input>
          </el-form-item>
          </el-col>


          <el-col :span="12">
            <el-form-item label="车型类别" label-width="100px" prop="carTypeId" >
              <el-select v-model="editForm.carTypeId" placeholder="请选择"  :disabled="editForm.id==0?false:true" style="width: 100%;" @change="onCarTypeChange()">
                <el-option
                  v-for="item in carTypeList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="申报类型" label-width="100px" prop="productTypeIds" >
              <el-cascader  style="width: 100%;" :disabled="editForm.id==0?false:true"
                  v-model="editForm.productTypeIds"
                  :options="testProductTypeList"
                  :props="{ expandTrigger: 'click', value: 'id', label: 'name' }"
                  @change="onProductTypeChange"
                  ></el-cascader>
            </el-form-item>
          </el-col>

        </el-row>


        <el-row>
        <el-col :span="12">
        <el-form-item label="业务经理" label-width="100px" prop="customerName">
          <el-select v-model="editForm.customerName"   placeholder="请选择" style="width: 45%;">
              <el-option
                v-for="item in customerNameList"
                :key="item.id"
                :label="item.name"
                :value="item.name">
              </el-option>
            </el-select>
        </el-form-item>
        </el-col>

        <el-col :span="5">
        <el-form-item label="产品名称" label-width="100px" prop="name">
          <el-input v-model="editForm.name" autocomplete="off" :disabled="editForm.id==0?false:true" ></el-input>
        </el-form-item>
        </el-col>
        <el-col :span="5">
        <el-form-item label="产品型号" label-width="100px" prop="model">
          <el-input v-model="editForm.model" autocomplete="off" :disabled="editForm.id==0?false:true" ></el-input>
        </el-form-item>
        </el-col>
        </el-row>


        <el-row>
        <el-col :span="6">
        <el-form-item label="建议完成时间" label-width="100px" prop="suggestTime">
          <el-date-picker
                v-model="editForm.suggestTime"
                type="datetime"
                value-format="timestamp"
                placeholder="选择日期时间">
              </el-date-picker>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="是否重要车型" label-width="150px" prop="importance">
          <el-select v-model="editForm.importance" placeholder="请选择">
            <el-option :key="1" label="是" :value="1"></el-option>
            <el-option :key="2" label="否" :value="2"></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="原因" label-width="100px" prop="cause">
          <el-input v-model="editForm.cause" autocomplete="off"></el-input>
        </el-form-item>
        </el-col>
        </el-row>

          <!-- <el-row>
          <el-col :span="5">

          </el-col>
          </el-row> -->


        <el-row v-if="this.userRole==7">
          <el-col :span="24">
            <el-form-item label="检测任务" label-width="100px" prop="testTasks">
              <el-button size="mini" type="primary" @click="showAddOrderTask()">增加检测任务</el-button>
              <table class="test-item-table" v-if="this.userRole==7">
                <tr>
                  <th>VIN</th>
                  <th>检测产品类别</th>
                  <th>检测费</th>
                  <th>场地费</th>
                  <!-- <th>检测费(成本)</th>
                  <th>场地费(成本)</th> -->
                  <!-- <th>备注</th> -->
                  <th>&nbsp;</th>
                </tr>
                <tr v-for="(item,index) in editForm.testTasks">
                  <td>{{item.vin}}</td>
                  <td>{{item.productTypeName1}}/{{item.productTypeName2}}</td>
                  <td>{{item.priceItemPay}}</td>
                  <td>{{item.priceSitePay}}</td>
                 <!-- <td>{{item.priceItemCost}}</td>
                  <td>{{item.priceSiteCost}}</td> -->
                  <!-- <td>{{item.itemNote}}</td> -->
                  <td>
                    <el-button type="primary" size="mini" @click="onTaskEditClick(index)">编辑</el-button>
                    <el-button type="warning" size="mini" @click="removeOrderTask(index)">删除</el-button>
                  </td>
                </tr>
              </table>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row v-if="this.userRole!=7">
          <el-col :span="24">
            <el-form-item label="检测任务" label-width="100px" prop="testTasks">
              <el-button size="mini" type="primary" @click="showAddOrderTask()">增加检测任务</el-button>
              <table class="test-item-table" v-if="this.userRole!=7">
                <tr>
                  <th>VIN</th>
                  <th>检测产品类别</th>
                  <th>检测费</th>
                  <th>场地费</th>
                  <th>检测费(成本)</th>
                  <th>场地费(成本)</th>
                  <!-- <th>备注</th> -->
                  <th>&nbsp;</th>
                </tr>
                <tr v-for="(item,index) in editForm.testTasks">
                  <td>{{item.vin}}</td>
                  <td>{{item.productTypeName1}}/{{item.productTypeName2}}</td>
                  <td>{{item.priceItemPay}}</td>
                  <td>{{item.priceSitePay}}</td>
                 <td>{{item.priceItemCost}}</td>
                  <td>{{item.priceSiteCost}}</td>
                  <!-- <td>{{item.itemNote}}</td> -->
                  <td>
                    <el-button type="primary" size="mini" @click="onTaskEditClick(index)">编辑</el-button>
                    <el-button type="warning" size="mini" @click="removeOrderTask(index)">删除</el-button>
                  </td>
                </tr>
              </table>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row v-if="editForm.productTypeId1 &&this.userRole!=7">
          <el-col :span="24">
            <div class="chose-role" >
              <span style="color:red">*</span>检测方案核定-A:
              <el-select v-model="editForm.a" placeholder="请选择" size="mini">
                <el-option v-for="item in userListAB" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span> 参 数 填 报 - B:
              <el-select v-model="editForm.b" placeholder="请选择" size="mini">
                <el-option v-for="item in userListAB" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span>方案参数审核-C:
              <el-select v-model="editForm.c" placeholder="请选择" size="mini">
                <el-option v-for="item in userListC" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span> 报 告 出 具 - D:
              <el-select v-model="editForm.d" placeholder="请选择" size="mini">
                <el-option v-for="item in userListD" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">* </span> 报 告 审 核 - E:
              <el-select v-model="editForm.e" placeholder="请选择" size="mini">
                <el-option v-for="item in userListE" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span> 批  准 ——— F:
              <el-select v-model="editForm.f" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role" v-if="editForm.productTypeId1 == 1 || editForm.productTypeId1 == 2 ">
              <span style="color:red">*</span> 原 始 记 录 - G:
              <el-select v-model="editForm.g" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>
            <div class="chose-role" v-if="editForm.productTypeId1 == 1 || editForm.productTypeId1 == 2">
              <span style="color:red">*</span>提交及追踪-H:
              <el-select v-model="editForm.h" placeholder="请选择" size="mini" @change="onUserHChange(editForm.h)" >
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <!-- <div class="chose-role" v-if="editTaskForm.productTypeId1 == 1">
              <span style="color:red">*</span>检测机构已提交-I:
              <el-select v-model="editTaskForm.i" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div> -->
            <!-- <div class="chose-role" v-if="editTaskForm.productTypeId1 == 2">
              <span style="color:red">*</span>检测报告生成-J:
              <el-select v-model="editTaskForm.j" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div> -->
            <div class="chose-role" v-if="editForm.productTypeId1 == 3 || editForm.productTypeId1 == 4|| editForm.productTypeId1 == 19 ">
              <span style="color:red">*</span> 企 业 提 交 - K :
              <el-select v-model="editForm.k" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div>
            <div class="chose-role" v-if="editForm.productTypeId1 == 3">
              <span style="color:red">*</span> 原 始 记 录 - G :
              <el-select v-model="editForm.g" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>
            <!-- <div class="chose-role" v-if="editTaskForm.productTypeId1 == 2">
              <span style="color:red">*</span> 反  馈 ——— L :
              <el-select v-model="editTaskForm.l" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div>
            <div class="chose-role" v-if="editTaskForm.productTypeId1 == 2">
              <span style="color:red">*</span> 反 馈 提 交 - M :
              <el-select v-model="editTaskForm.m" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div>
            <div class="chose-role" v-if="editTaskForm.productTypeId1 == 2">
              <span style="color:red">*</span> 审 核 通 过 - N:
              <el-select v-model="editTaskForm.n" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div> -->
            <div class="chose-role" v-if="editForm.productTypeId1 == 19">
              <span style="color:red">*</span> 客 户 确 认 - O:
              <el-select v-model="editForm.o" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="成本总价" label-width="100px" prop="priceCost" v-if="this.userRole!=7">
              <el-input v-model="editForm.priceCost" type="number" autocomplete="off" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="总报价" label-width="100px" prop="price">
              <el-input v-model="editForm.price" type="number" autocomplete="off" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际收款" label-width="100px" prop="price">
              <el-input-number v-model="editForm.payPrice" controls-position="right" :min="0" style="width: 100%;" @change="onPayPriceChange"></el-input-number>
            </el-form-item>
          </el-col>
        </el-row>



        <el-form-item label="备注" label-width="100px">
          <el-input v-model="editForm.note" autocomplete="off" placeholder="联系电话:"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editFormVisible = false">取 消</el-button>
        <el-button type="primary" @click.native.prevent="submitForm" :loading="loading" v-if="this.userRole!=7">保存</el-button>
        <el-button type="primary" @click.native.prevent="submitForm" :loading="loading" v-if="this.userRole==7">暂存</el-button>
        <!-- <el-button type="success" @click.native.prevent="submitFormNext" :loading="loading">下发任务</el-button> -->
      </div>
    </el-dialog>

    <!-- 添加检测任务 -->
    <el-dialog :visible.sync="showEditTaskDialog" width="80%" top="5vh" >
      <el-form :model="editTaskForm" ref="editTaskForm" :rules="editTaskRules">
        <el-row>
          <!-- <el-col :span="12">
            <el-form-item label="车型类别" label-width="100px" prop="carTypeId">
              <el-select v-model="editTaskForm.carTypeId" placeholder="请选择" style="width: 100%;" @change="onCarTypeChange()">
                <el-option
                  v-for="item in carTypeList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
          <!-- <el-col :span="6">
          <el-form-item label="产品名称" label-width="100px" prop="name">
            <el-input v-model="editTaskForm.name" autocomplete="off" :disabled="carEntDisableds"></el-input>
          </el-form-item>
          </el-col>
          <el-col :span="6">
          <el-form-item label="产品型号" label-width="100px" prop="model">
            <el-input v-model="editTaskForm.model" autocomplete="off" :disabled="carEntDisableds"></el-input>
          </el-form-item>
          </el-col> -->
          <el-col :span="6">
          <el-form-item label="VIN" label-width="100px" prop="vin">
            <el-input v-model="editTaskForm.vin" autocomplete="off" :disabled="carEntDisableds"></el-input>
          </el-form-item>
          </el-col>
          <el-col :span="6">
          <el-form-item label="生产年月" label-width="100px" prop="prDate" >
            <el-date-picker :disabled="carEntDisableds"
              v-model="editTaskForm.prDate"
              type="month"
              value-format="timestamp"
              format="yyyy年MM月"
              placeholder="选择生产年月">
            </el-date-picker>
          </el-form-item>
          </el-col>
          <el-col :span="6">
          <el-form-item label="颜色" label-width="100px" prop="color">
            <el-input v-model="editTaskForm.color" autocomplete="off" :disabled="carEntDisableds"></el-input>
          </el-form-item>
          </el-col>
          <el-col :span="6">
          <el-form-item label="是否送样" label-width="100px" prop="sendSample" >
            <el-select v-model="editTaskForm.sendSample" placeholder="请选择"  :disabled="carEntDisableds" @change="userCarList">
              <el-option :key="1" label="是" :value="1"></el-option>
              <el-option :key="2" label="否" :value="2"></el-option>
            </el-select>
          </el-form-item>
          </el-col>
        </el-row>
        <el-row>

          <el-col :span="12">
          <el-form-item label="收车人" label-width="100px" prop="carPeople" v-if="editTaskForm.sendSample==1">
            <el-select v-model="editTaskForm.carPeople"  multiple placeholder="请选择" style="width: 100%;">
              <el-option v-for="item in userAllCarList" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          </el-col>

          <el-col :span="6">
          <el-form-item label="收车人备注" label-width="100px" prop="carPeopleNote" v-if="editTaskForm.sendSample==1">
            <el-input v-model="editTaskForm.carPeopleNote" autocomplete="off" ></el-input>
          </el-form-item>
          </el-col>

          <el-col :span="6">
          <el-form-item label="拟送样时间" label-width="100px" prop="sendSampleTime" v-if="editTaskForm.sendSample==1">
            <el-date-picker
                  v-model="editTaskForm.sendSampleTime"
                  type="datetime"
                  value-format="timestamp"
                  placeholder="选择送样时间">
                </el-date-picker>
          </el-form-item>
          </el-col>


          <!-- <el-col :span="12">
            <el-form-item label="申报类型" label-width="100px" prop="productTypeIds">
              <el-cascader  style="width: 100%;"
                  v-model="editTaskForm.productTypeIds"
                  :options="testProductTypeList"
                  :props="{ expandTrigger: 'click', value: 'id', label: 'name' }"
                  @change="onProductTypeChange"
                  ></el-cascader>
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
          <el-form-item label="无任务车辆" label-width="100px" prop="carId" v-if="editTaskForm.sendSample==2&&editTaskForm.id==0">
            <el-select v-model="editTaskForm.carId"   placeholder="请选择" style="width: 100%;"
            @change="carVin">
                <el-option
                  v-for="item in carVinList"
                  :key="item.id"
                  :label="item.name+'-'+item.model+'-VIN:'+item.vin"
                  :value="item.id">
                </el-option>
              </el-select>
          </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="检测场地" label-width="100px" prop="siteId">
              <el-select v-model="editTaskForm.siteId " placeholder="请选择" style="width: 100%;" @change="computeTaskPrice()">
                <el-option
                  v-for="item in testSiteList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="检测机构" label-width="100px" prop="orgId">
              <el-select v-model="editTaskForm.orgId" placeholder="请选择" style="width: 100%;"  @change="onOrgCost()">
                <el-option
                  v-for="item in orgList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <div  v-if="editTaskForm.orgId != 0&&editTaskForm.orgId != ''&&editTaskForm.orgId != null">
            <el-form-item label="打包项目" label-width="100px" prop="groupId">
              <el-select v-model="editTaskForm.groupId"  placeholder="请选择" style="width: 100%;" :disabled="orgDisableds" clearable  @change="onGroupChange" @clear="GroupChange">
                <el-option
                  v-for="item in groupList"
                  :key="item.id"
                  :label="item.name + '(¥'+item.groupPrice+')'"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <div  v-if="editTaskForm.orgId == 0||editTaskForm.orgId == ''||editTaskForm.orgId == null">
              <el-form-item label="打包项目" label-width="100px" prop="groupId">
              <el-select v-model="editTaskForm.groupId"  placeholder="请先选择检测机构" style="width: 100%;" :disabled="orgDisableds" clearable  @change="onGroupChange" @clear="GroupChange">
                <el-option
                  v-for="item in groupList"
                  :key="item.id"
                  :label="item.name + '(¥'+item.groupPrice+')'"
                  :value="item.id">
                </el-option>
              </el-select>
            </el-form-item>

            </div>
          </el-col>
        </el-row>

        <!-- <el-row>
        <el-col :span="6">
        <el-form-item label="建议完成时间" label-width="100px" prop="suggestTime">
          <el-date-picker
                v-model="editTaskForm.suggestTime"
                type="datetime"
                value-format="timestamp"
                placeholder="选择日期时间">
              </el-date-picker>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="是否重要车型" label-width="110px" prop="importance">
          <el-select v-model="editTaskForm.importance" placeholder="请选择">
            <el-option :key="1" label="是" :value="1"></el-option>
            <el-option :key="2" label="否" :value="2"></el-option>
          </el-select>
        </el-form-item>
        </el-col>
        <el-col :span="6">
        <el-form-item label="原因" label-width="100px" prop="cause">
          <el-input v-model="editTaskForm.cause" autocomplete="off"></el-input>
        </el-form-item>
        </el-col>
        </el-row> -->
        <el-row v-if="this.userRole==7">
          <el-col :span="24">
            <el-form-item label="检测项目" label-width="100px" prop="testItems">
              <el-button size="mini" type="primary" @click="showChoseItemDialog()">增加项目</el-button>
              <table class="test-item-table" v-if="this.userRole==7">
                <tr>
                  <th>项目代码</th>
                  <th>检测项目</th>
                  <th>单价</th>
                  <th>场地费</th>
                  <th>数量</th>
                  <th>折扣</th>
                  <th>价格</th>
                  <th>场地折扣</th>
                  <th>场地价格</th>
                  <!-- <th>成本折扣</th>
                  <th>成本</th>

                  <th>场地成本价格</th> -->
                  <th>备注</th>
                </tr>
                <tr v-for="(item,index) in editTaskForm.testItems">
                  <td :style="{backgroundColor: item.inGroup?'#EDF2FC':''}">{{item.serialNumber}}</td>
                  <td :style="{backgroundColor: item.inGroup?'#EDF2FC':''}">{{item.itemName}}</td>
                  <td>{{item.itemPrice}}</td>
                  <td>{{item.sitePrice}}</td>
                  <td>
                    <el-input-number v-model="item.num" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="10" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>
                    <el-input-number v-model="item.rebate" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="100" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>{{item.price}}</td>
                  <td>
                    <el-input-number v-model="item.siteRebate" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="100" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>{{parseFloat(item.priceSite).toFixed(2)}}</td>
                  <!-- <td>
                    <el-input-number v-model="item.costRebate" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="100" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>{{item.priceCost}}</td>

                  <td>{{item.priceSiteCost}}</td> -->

                  <td>
                    <el-input type="textarea" :rows="2" placeholder="" v-model="item.itemNote" size="mini" style="width: 150px;" controls-position="right" ></el-input>
                  </td>
                  <!-- <td>
                    <el-select v-model="item.carIds" placeholder="请选择" size="mini"
                        :multiple="true"
                        :multiple-limit="item.num">
                      <el-option
                        v-for="item in carList"
                        :key="item.id"
                        :label="item.vin"
                        :value="item.id"></el-option>
                    </el-select>
                  </td> -->
                </tr>
              </table>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row v-if="this.userRole!=7">
          <el-col :span="24">
            <el-form-item label="检测项目" label-width="100px" prop="testItems">
              <el-button size="mini" type="primary" @click="showChoseItemDialog()">增加项目</el-button>
              <table class="test-item-table" >
                <tr>
                  <th>项目代码</th>
                  <th>检测项目</th>
                  <th>单价</th>
                  <th>场地费</th>
                  <th>数量</th>
                  <th>折扣</th>
                  <th>价格</th>
                  <th>场地折扣</th>
                  <th>场地价格</th>
                  <th>成本折扣</th>
                  <th>成本</th>

                  <th>场地成本价格</th>
                  <th>备注</th>
                </tr>
                <tr v-for="(item,index) in editTaskForm.testItems">
                  <td :style="{backgroundColor: item.inGroup?'#EDF2FC':''}">{{item.serialNumber}}</td>
                  <td :style="{backgroundColor: item.inGroup?'#EDF2FC':''}">{{item.itemName}}</td>
                  <td>{{item.itemPrice}}</td>
                  <td>{{item.sitePrice}}</td>
                  <td>
                    <el-input-number v-model="item.num" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="10" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>
                    <el-input-number v-model="item.rebate" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="100" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>{{item.price}}</td>
                  <td>
                    <el-input-number v-model="item.siteRebate" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="100" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>{{parseFloat(item.priceSite).toFixed(2)}}</td>
                  <td>
                    <el-input-number v-model="item.costRebate" size="mini" style="width: 100px;" controls-position="right" :min="0" :max="100" label="" @change="computeTaskPrice()"></el-input-number>
                  </td>
                  <td>{{item.priceCost}}</td>

                  <td>{{item.priceSiteCost}}</td>

                  <td>
                    <el-input type="textarea" :rows="2" placeholder="" v-model="item.itemNote" size="mini" style="width: 150px;" controls-position="right" ></el-input>
                  </td>
                  <!-- <td>
                    <el-select v-model="item.carIds" placeholder="请选择" size="mini"
                        :multiple="true"
                        :multiple-limit="item.num">
                      <el-option
                        v-for="item in carList"
                        :key="item.id"
                        :label="item.vin"
                        :value="item.id"></el-option>
                    </el-select>
                  </td> -->
                </tr>
              </table>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="6">
            <el-form-item label="检测费报价" label-width="100px">
              <el-input v-model="editTaskForm.priceItemPay" type="number" autocomplete="off" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="场地费报价" label-width="100px">
              <el-input v-model="editTaskForm.priceSitePay" type="number" autocomplete="off" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检测成本" label-width="100px" v-if="this.userRole!=7">
              <el-input v-model="editTaskForm.priceItemCost" type="number" autocomplete="off" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="场地费成本" label-width="100px" v-if="this.userRole!=7">
              <el-input v-model="editTaskForm.priceSiteCost" type="number" autocomplete="off" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <!-- <el-row v-if="editTaskForm.productTypeId1">
          <el-col :span="24">
            <div class="chose-role">
              <span style="color:red">*</span>检测方案核定-A:
              <el-select v-model="editTaskForm.a" placeholder="请选择" size="mini">
                <el-option v-for="item in userListAB" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span> 参 数 填 报 - B:
              <el-select v-model="editTaskForm.b" placeholder="请选择" size="mini">
                <el-option v-for="item in userListAB" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span>方案参数初审-C:
              <el-select v-model="editTaskForm.c" placeholder="请选择" size="mini">
                <el-option v-for="item in userListC" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span> 报 告 出 具 - D:
              <el-select v-model="editTaskForm.d" placeholder="请选择" size="mini">
                <el-option v-for="item in userListD" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">* </span>  复    核 ——— E :
              <el-select v-model="editTaskForm.e" placeholder="请选择" size="mini">
                <el-option v-for="item in userListE" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role">
              <span style="color:red">*</span> 批  准 ——— F:
              <el-select v-model="editTaskForm.f" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>
            <div class="chose-role" v-if="editTaskForm.productTypeId1 == 1 || editTaskForm.productTypeId1 == 2 ">
              <span style="color:red">*</span> 原 始 记 录 - G:
              <el-select v-model="editTaskForm.g" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>
            <div class="chose-role" v-if="editTaskForm.productTypeId1 == 1 || editTaskForm.productTypeId1 == 2">
              <span style="color:red">*</span>提交及追踪-H:
              <el-select v-model="editTaskForm.h" placeholder="请选择" size="mini" @change="onUserHChange" >
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option>
              </el-select>
            </div>

            <div class="chose-role" v-if="editTaskForm.productTypeId1 == 3 || editTaskForm.productTypeId1 == 4|| editTaskForm.productTypeId1 == 19 ">
              <span style="color:red">*</span> 企 业 提 交 - K :
              <el-select v-model="editTaskForm.k" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div>
            <div class="chose-role" v-if="editTaskForm.productTypeId1 == 3">
              <span style="color:red">*</span> 原 始 记 录 - G :
              <el-select v-model="editTaskForm.g" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"></el-option>
              </el-select>
            </div>

            <div class="chose-role" v-if="editTaskForm.productTypeId1 == 19">
              <span style="color:red">*</span> 客 户 确 认 - O:
              <el-select v-model="editTaskForm.o" placeholder="请选择" size="mini">
                <el-option v-for="item in userList" :key="item.id" :label="item.nickname" :value="item.id"> </el-option></el-select>
            </div>
          </el-col>
        </el-row> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showEditTaskDialog = false">关 闭</el-button>
        <el-button type="primary" @click.native.prevent="addOrderTask">确定</el-button>
      </div>
    </el-dialog>
    <!-- 添加检测项目 -->
    <el-dialog :visible.sync="showAddItemDialog" width="650px">
      <el-form :model="addItemForm" ref="addItemForm">
        <!-- <el-form-item label="检测项目" label-width="100px" prop="items">
          <el-cascader  style="width: 100%;"
              v-model="addItemForm.items"
              :options="addItems"
              :props="{ expandTrigger: 'click', value: 'id', label:'label', multiple: true }"
              ></el-cascader>
        </el-form-item> -->
        <el-form-item label="检测项目" label-width="100px" prop="items" >
          <el-select v-model="addItemForm.items"  multiple placeholder="请选择" style="width: 100%;">
            <el-option v-for="item in addItems" :key="item.id" :label="item.serialNumber+'-'+item.itemName" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showAddItemDialog = false">关 闭</el-button>
        <el-button type="primary" @click.native.prevent="addToTaskItems">确定</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {validPhone} from '@/common/utils/validate.js'
import request from '@/common/utils/request.js'
import util from '../../../common/utils/util.js'
import {getToken} from '../../../common/utils/auth.js'
import {getTestGroupItem} from "../../../api/test_group.js"
import {getTestOrderList, saveOrNextTestOrder, deleteTestOrder, taskToUser, getOrderInfo, orderNext, updateOrder ,getSubmitOrder} from "../../../api/test_order.js";
import {getAllTestCarEnterpriseList,getUserTestCarEnterpriseList} from "../../../api/test_car_enterprise.js"
import {getTestCarListByEntId,getTestCarListByEntVin} from "../../../api/test_car.js"
import {getAllCarTypeList} from '../../../api/car_type.js'
import {getAllTestProductTypeList} from '../../../api/test_product_type.js'
import {getAllTestGroupListByParam,getTestGroupItemParam} from '../../../api/test_group.js'
import {getAllTestSiteList} from '../../../api/test_site.js'
import {getTestSitePrice, getTestSiteItemList} from '../../../api/test_site_price.js'
import {getAllUserList,getUser,getAllCarList,getUserRole} from '../../../api/user.js'
import {getAllTestOrgList} from '../../../api/test_org.js'
import {getTestItemList2, getTestItemListByGroupId} from '../../../api/test_item.js'
import {getAllTestoperationManagerList} from "@/api/test_operation_manager";
import {getTesGroupPriceLists} from "../../../api/test_org_price_manage";



export default {
  name: "testOrderManage",
  data() {
    return {
      total: 0,
      pageSize: 10,
      currentPage: 1,
      tableData: [],
      tableHeight: 200,
      editFormVisible:false,
      loading: false,
      suggestTime:'',
      groupPriceCost:0,
      testGroupItems:[],
      userRole:0,
      tiemif :0,
      editForm: {
        id: 0,
        tOrderId:0,
        carEnterpriseId:0,
        testTasks:[],
        priceCost: 0, // 成本总价
        price: 0, // 计算总价
        payPrice: 0, // 最终价
        payPriceStatus: 0, // 最终价是否修改过
        rebate: 100, // 车企默认折扣
        siteRebate: 100, // 车企场地默认折扣
        next: 0,
        brand:'',
        customerName:'',
        suggestTime:'',
        importance:'',
        cause:'',
        carTypeId:'',
        productTypeIds:[],
        productTypeId1: '', // 产品类别1级分类
        productTypeId2: '', // 产品类别2级分类
        productTypeName1:'',
        productTypeName2:'',
        name:'',
        model:'',
        a: '',
        b: '',
        c: '',
        d: '',
        e: '',
        f: '',
        g: '',
        h: '',
        i: '',
        j: '',
        k: '',
        l: '',
        m: '',
        n: '',
        o: '',





      },
      editRules: {
        carEnterpriseId: [{ required: true, message:"请选择车企", trigger: 'blur'}],
        carTypeId: [{ required: true, message:"请选择车型类别", trigger: 'blur'}],
        productTypeIds: [{ required: true, message:"请选择申报类型", trigger: 'blur'}],
        customerName: [{ required: true, message:"请选择业务经理", trigger: 'blur'}],
        name: [{ required: true, message:"请填写产品名称", trigger: 'blur'}],
        model: [{ required: true, message:"请填写产品型号", trigger: 'blur'}],

      },
      loadingDiv: null,
      searchForm: {
        orderStatus: 0,
        carEnterpriseId:'',
        carTypeId:'',
        productTypeIds:'',
        customerName:'',

      },
      carEntList:[],
      carList:[],
      carVinList:[],
      carTypeList:[],
      testProductTypeList: [],
      groupList: [],
      groupItemList:[],
      testSiteList:[],
      userList:[],
      userAllCarList:[],
      orgList:[],
      hasDxDisabled:true,
      nextShow: false,
      customerNameList:[],

      showEditTaskDialog: false,
      editTaskIndex: -1,
      editTaskForm: {
        id: 0,
        tid:0,
        tOrderId: 0,
        carTypeId: '', // 车型
        carTypeName: '',
        productTypeId1: '', // 产品类别1级分类
        productTypeId2: '', // 产品类别2级分类
        productTypeName1: '',
        productTypeName2: '',
        siteId: '',
        orgId: '',
        groupId: '', // 套餐id
        groupName: '',
        groupPrice: '',
        groupItemIds: [],
        groupItemTIds: [],
        priceItemCost: 0,
        priceSiteCost: 0,
        priceItemPay: 0,
        priceSitePay: 0,
        costRebate:0,
        carPeopleNote:'',

        sendSampleTime:'',
        carPeople:'',

        prDate:'',
        name:'',
        model:'',
        vin:'',
        color:'',
        sendSample: 0,
        suggestTime:'',
        importance: 0,
        cause:'',
        carId: 0,

        note: '',
        testItems:[],
        productTypeIds:[],



        //公告：ABCDEFGHIK 1
        //达标：ABCDEFGHJKLMN 2
        //CCC：ABCDEFKG 3
        //环保：ABCDEFK 4
        //其他：ABCDEFKO 19
      },
      editTaskRules: {
        // carTypeId: [{ required: true, message:"请选择车企", trigger: 'blur'}],
        // productTypeIds: [{ required: true, message:"请选择申报类型", trigger: 'blur'}],
        siteId: [{ required: true, message:"请选择检测场地", trigger: 'blur'}],
        orgId: [{ required: true, message:"请选择检测机构", trigger: 'blur'}],
        testItems: [{ required: true, message:"请添加检测项目", trigger: 'blur'}],

      },

      showAddItemDialog: false,
      addItemForm:{
        items:[],
        tiemif: 0,
      },
      addItems:[],
      addItemsGroup:[],

      siteItemList: [],
    }
  },
  watch:{
    $route (to, from ) {
      // 监听路由变化, 实现类似 小程序的 onShow 事件
      if (to.path === '/task/test_order_manage/0') {
        if(this.nextShow){
          this.editFormVisible = true;
          this.nextShow = false;
        }
      }
    }

  },
  computed:{
    carEntDisabled(){
      if(this.editForm.testTasks && this.editForm.testTasks.length > 0){
        return true;
      }
      return false;
    },
    carEntDisableds(){
      if(util.isEmpty(this.editTaskForm.carId)){
        return false;
      }
      return true;
    },
    orgDisableds(){
      if(util.isEmpty(this.editTaskForm.orgId)){
        return true;
      }
      return false;
    },
    userListAB(){
      if(util.isEmpty(this.userList)){
        return [];
      }

      let arr = [];
      arr.push({id:0, nickname:'不适用'});
      for(let i in this.userList){
        if(this.userList[i].id == this.editForm.c){
          continue;
        }
        arr.push(this.userList[i]);
      }

      return arr;
    },
    userListC(){
      if(util.isEmpty(this.userList)){
        return [];
      }

      let arr = [];
      for(let i in this.userList){
        if(this.userList[i].id == this.editForm.a || this.userList[i].id == this.editForm.b){
          continue;
        }
        arr.push(this.userList[i]);
      }

      return arr;
    },

    userListD(){
      if(util.isEmpty(this.userList)){
        return [];
      }

      let arr = [];
      for(let i in this.userList){
        if(this.userList[i].id == this.editForm.e){
          continue;
        }
        arr.push(this.userList[i]);
      }

      return arr;
    },

    userListE(){
      if(util.isEmpty(this.userList)){
        return [];
      }

      let arr = [];
      for(let i in this.userList){
        if(this.userList[i].id == this.editForm.d){
          continue;
        }
        arr.push(this.userList[i]);
      }

      return arr;
    },
  },


  created() {
    let step=this.$route.params.step;
    if(step == 0){
      this.searchForm.orderStatus=0;
    }else if(step == 1){
      this.searchForm.orderStatus=1;
    }else if(step == 2){
      this.searchForm.orderStatus=2;
    }
  },
  mounted() {
    this.init();
    this.getDataList(this.currentPage);

    this.$nextTick(() => {
        this.tableHeight = document.documentElement.clientHeight - 198;
    })
    window.onresize = () => {
      this.$nextTick(() => {
          this.tableHeight = document.documentElement.clientHeight - 198;
      })
    }

    let t = getToken();
    this.fileBaseUrl = this.$adminApiUrl+"/file/get?_t="+t+"&f=";
  },
  methods: {
    onUserHChange(e){
      switch(this.editForm.productTypeId1){
        case 1: // 公告
          this.editForm.i = e;
          this.editForm.k = e;
          break;
        case 2: // 达标车型
          this.editForm.j = e;
          this.editForm.k = e;
          this.editForm.l = e;
          this.editForm.m = e;
          this.editForm.n = e;
          break;
      }
    },
    submitOrder(index, row){
      getSubmitOrder({id: row.id}).then(res=>{
        if(res.code == 0) {
            this.$alert(res.msg, "失败", {dangerouslyUseHTMLString:true,type:'warning'})
            this.search();
          }else if(res.code == 1) {
            this.$alert(res.msg, "成功", {dangerouslyUseHTMLString:true,type:'success'})
            this.search();
          }
        })

    },

    handleOrderEdit(index, row){

      // console.log("修改");
      getOrderInfo({id: row.id}).then(res=>{
        // console.log(res.data);
        this.editForm = res.data;

        if(!util.isEmpty(this.editForm.testTasks)){
          for(let i in this.editForm.testTasks){
            let tasks = this.editForm.testTasks[i];
             if(!util.isEmpty(tasks.carPeople)){
               tasks.carPeople = tasks.carPeople.split(",").map(Number);
               }else {
                 tasks.carPeople = [];
               }
            if(!util.isEmpty(tasks.groupItemTIds)){
              let arrStr = tasks.groupItemTIds.split(",")
              let arr = [];

              for(let i in arrStr){
                if(!util.isEmpty(arrStr[i])){
                  arr.push(parseInt(arrStr[i]));
                }
              }

              tasks.groupItemTIds = arr;
            }else{
              tasks.groupItemTIds = [];
            }
          }
        }
        this.editForm.productTypeIds=[this.editForm.productTypeId1, this.editForm.productTypeId2];
        this.editForm.productTypeIds=this.editForm.productTypeIds.map(Number);
        // console.log(this.editForm.testTasks[0]);
        if(this.editForm.testTasks[0]!=null&&this.editForm.testTasks[0]!=[]){
          this.editForm.productTypeName1 = this.editForm.testTasks[0].productTypeName1;
          this.editForm.productTypeName2 = this.editForm.testTasks[0].productTypeName2;
          this.editForm.productTypeId1 = this.editForm.testTasks[0].productTypeId1;
          this.editForm.productTypeId2 = this.editForm.testTasks[0].productTypeId2;
          this.editForm.productTypeIds=[this.editForm.productTypeId1, this.editForm.productTypeId2];
          this.editForm.suggestTime = this.editForm.testTasks[0].suggestTime;
          this.editForm.importance = this.editForm.testTasks[0].importance;
          this.editForm.cause = this.editForm.testTasks[0].cause;
          // this.editForm.name=this.editForm.testTasks[0].name;
          // this.editForm.model=this.editForm.testTasks[0].model;
        }

        let param = {
          productTypeIds: this.editForm.productTypeId1,
        }
        getUser(param).then(res => {        if(res.code == 1) {          this.userList = res.data;          // console.log(this.userList)        }        }).catch(res => {        });
        // console.log("123")
        // console.log(this.editForm.testTasks[0].productTypeName1)
        this.editFormVisible = true;

      })



    },
    handleOrderTaskNext(index, row){
      //公告：ABCDEFGHIK 1
      //达标：ABCDEFGHJKLMN 2
      //CCC：ABCDEFKG 3
      //环保：ABCDEFK 4
      //其他：ABCDEFKO 19
      // console.log(row)
      switch(row.productTypeId1-0){
        case 1:
          if(util.isEmpty(row.a)
            || util.isEmpty(row.b)
            || util.isEmpty(row.c)
            || util.isEmpty(row.d)
            || util.isEmpty(row.e)
            || util.isEmpty(row.f)
            || util.isEmpty(row.g)
            || util.isEmpty(row.h)
            || util.isEmpty(row.i)
            || util.isEmpty(row.k)){
            // console.log("123")
            this.$message.error('请选择检测工程师');
            return;
          }
          break;
        case 2:
          if(util.isEmpty(row.a)
            || util.isEmpty(row.b)
            || util.isEmpty(row.c)
            || util.isEmpty(row.d)
            || util.isEmpty(row.e)
            || util.isEmpty(row.f)
            || util.isEmpty(row.g)
            || util.isEmpty(row.h)
            || util.isEmpty(row.j)
            || util.isEmpty(row.k)
            || util.isEmpty(row.l)
            || util.isEmpty(row.m)
            || util.isEmpty(row.n)){
            this.$message.error('请选择检测工程师');
            return;
          }
          break;
        case 3:

          if(util.isEmpty(row.a)
            || util.isEmpty(row.b)
            || util.isEmpty(row.c)
            || util.isEmpty(row.d)
            || util.isEmpty(row.e)
            || util.isEmpty(rowm.f)
            || util.isEmpty(row.k)
            || util.isEmpty(row.g)){
            this.$message.error('请选择检测工程师');
            return;
          }
          break;
        case 4:

          if(util.isEmpty(row.a)
            || util.isEmpty(row.b)
            || util.isEmpty(row.c)
            || util.isEmpty(row.d)
            || util.isEmpty(row.e)
            || util.isEmpty(row.f)
            || util.isEmpty(row.k)){
            this.$message.error('请选择检测工程师');
            return;
          }
          break;
        case 19:
          if(util.isEmpty(row.a)
            || util.isEmpty(row.b)
            || util.isEmpty(row.c)
            || util.isEmpty(row.d)
            || util.isEmpty(row.e)
            || util.isEmpty(row.f)
            || util.isEmpty(row.k)
            || util.isEmpty(row.o)){
            this.$message.error('请选择检测工程师');
            return;
          }
          break;
      }


      const loadingDiv = util.showLoading("下发中")
      this.loading = true;
      orderNext({id: row.id}).then(res => {
        if(res.code == 0) {
          this.$alert(res.msg, "失败", {dangerouslyUseHTMLString:true,type:'warning'})
        }else if(res.code == 1) {
          this.$alert(res.msg, "成功", {dangerouslyUseHTMLString:true,type:'success'})
            .then(()=> {
              this.editFormVisible=false;
              this.getDataList(this.currentPage)
            })
        }
        this.loading = false;
        loadingDiv.close();
      }).catch(res => {
        this.loading = false;
        loadingDiv.close();
      })
    },
    loadCarList(){
      getTestCarListByEntId({carEnterpriseId: this.editForm.carEnterpriseId}).then(res=>{
        if(res.code == 1){
          this.carList = res.data;
        }
      });
      getTestCarListByEntVin({carEnterpriseId: this.editForm.carEnterpriseId,name:this.editForm.name,model:this.editForm.model}).then(res=>{
        if(res.code == 1){
          this.carVinList = res.data;
          // console.log("123")
          // console.log(this.carVinList)
        }
      });
    },

    userCarList(){
      if(this.editTaskForm.sendSample==1){
        getAllCarList().then(res => {        if(res.code == 1) {          this.userAllCarList = res.data;          // console.log(this.userAllCarList)        }      }).catch(res => {      });
      }

    },

    onPayPriceChange(){
      if(this.editForm.price != this.editForm.payPrice){
        this.editForm.payPriceStatus = 1;
      }
    },
    computeOrderPrice(){
      if(util.isEmpty(this.editForm.testTasks)){
        this.editForm.price = 0;
        this.editForm.payPrice = 0;
        this.editForm.payPriceStatus = 0;
        this.editForm.priceCost = 0;
        return ;
      }

      let price = 0;
      let priceCost = 0;
      for(let i in this.editForm.testTasks){
        // console.log(this.editForm.testTasks[i].priceItemPay)
        // console.log(this.editForm.testTasks[i].priceSitePay)
        price += this.editForm.testTasks[i].priceItemPay + this.editForm.testTasks[i].priceSitePay;
        priceCost += this.editForm.testTasks[i].priceItemCost + this.editForm.testTasks[i].priceSiteCost;
      }

      this.editForm.price = Number(parseFloat(price).toFixed(2));
      this.editForm.priceCost = Number(parseFloat(priceCost).toFixed(2));
      if(this.editForm.payPriceStatus == 0){
        this.editForm.payPrice = this.editForm.price;
      }


    },
    onTaskEditClick(index){
      this.editTaskIndex = index;
      this.editTaskForm = JSON.parse(JSON.stringify(this.editForm.testTasks[index]));

      this.editTaskForm.productTypeIds=[this.editTaskForm.productTypeId1, this.editTaskForm.productTypeId2];
      this.getGroupList();
      this.loadCarList();
      this.showEditTaskDialog = true;

      this.onOrgCost();

      getTestGroupItem({id: this.editTaskForm.groupId}).then(res=>{
        // console.log("1")
          // console.log(res)
          if(res.code == 1){
            let data = res.data;
            this.testGroupItems = data;
            // console.log("2")

          }else{
            this.$message.error("加载信息失败")
          }
        });

      if(this.editTaskForm.sendSample==1){        getAllCarList().then(res => {        if(res.code == 1) {          this.userAllCarList = res.data;          // console.log(this.userAllCarList)        }      }).catch(res => {      });      }
    },
    removeOrderTask(index){
      this.editForm.testTasks.splice(index, 1);
      this.computeOrderPrice();
    },
    execComputeTaskPrice(){

      // 计算价格
      let priceItemCost = 0;
      let priceSiteCost = 0;
      let priceItemPay = 0;
      let priceSitePay = 0;

      let items = this.editTaskForm.testItems;

      const param = {
      orgId: this.editTaskForm.orgId,
      groupId: this.editTaskForm.groupId,
      }




      getTesGroupPriceLists(param).then(res => {
        if(res.code == 1) {
          this.groupPriceCost = res.data.price;

          this.editTaskForm.priceItemCost += this.groupPriceCost;
          // console.log("1")
        }
      }).catch(res => {

      });



      for(let i in items){

        // console.log(items)
        // console.log(this.testGroupItems)
        let item = items[i];
        let num = 0;
        let numCost = 0;
        let cost = 0;
        if(item.inGroup==1){

          if(this.testGroupItems==null|this.testGroupItems==''){
            // console.log("2")
            // console.log(this.testGroupItems)
            num = 1;
          }else{
            for(let k in this.testGroupItems){
              if(this.testGroupItems[k].itemTId==item.itemTId){
                if(item.num<=this.testGroupItems[k].num){
                  num = 0;
                }else{
                  num = item.num-this.testGroupItems[k].num;
                }
              }
            }
          }


        }else{
          num = (item.num>=1)?(item.num):0;
        }

        if(item.inGroup==1){
          if(this.testGroupItems==null|this.testGroupItems==''){
            numCost = 1;
          }else{
            for(let k in this.testGroupItems){
              if(this.testGroupItems[k].itemTId==item.itemTId){
                if(item.num<=this.testGroupItems[k].num){
                  numCost = 0;
                }else{
                  numCost = item.num-this.testGroupItems[k].num;
                }
              }
            }

          }
        }else {
         numCost = (item.num>=1)?(item.num):0;
        }

        item.priceCost = item.itemPrice * numCost * item.costRebate / 100; // 成本
        item.price = item.itemPrice * num * item.rebate / 100; // 价格
        // item.priceCost = Math.round(item.itemPrice * numCost * item.costRebate / 100); // 成本
        item.priceSite = item.sitePrice * item.num * item.siteRebate / 100; // 场地费
        // item.priceSiteCost = Math.round(item.sitePrice * numCost * item.costSiteRebate / 100); // 场地费成本
        item.priceSiteCost = item.priceSiteCost * item.num ; // 场地费成本
        // item.costRebate = this.editTaskForm.costRebate;
        priceItemPay += item.price;

        // if(item.inG){

        // }
        // console.log(priceItemCost)

        priceItemCost += item.priceCost+cost;
        priceSitePay = priceSitePay+item.priceSite;
        priceSiteCost += item.priceSiteCost;
        // item.priceCost = cost
      }

      // 单项价格 + 套餐价
      // console.log(this.editTaskForm.groupPrice)
      if(!util.isEmpty(this.editTaskForm.groupPrice)){
        priceItemPay += this.editTaskForm.groupPrice;
      }


      this.editTaskForm.priceItemCost = priceItemCost;
      this.editTaskForm.priceSiteCost = priceSiteCost;
      this.editTaskForm.priceItemPay = priceItemPay;
      this.editTaskForm.priceSitePay = Number(parseFloat(priceSitePay).toFixed(2));
    },
    computeTaskPrice(){
      if(util.isEmpty(this.editTaskForm.testItems)){
        this.editTaskForm.priceItemCost = 0;
        this.editTaskForm.priceSiteCost = 0;
        this.editTaskForm.priceItemPay = 0;
        this.editTaskForm.priceSitePay = 0;
      }

      // 获取场地费
      this.siteItemList = [];
      if(util.isEmpty(this.editTaskForm.siteId)){
        this.execComputeTaskPrice();
      }else{
        // this.onGroupChange();
        getTestSiteItemList({siteId: this.editTaskForm.siteId}).then(res=>{
          if(res.code == 1){
            this.siteItemList = res.data;
            for(let i in this.editTaskForm.testItems){
              let item = this.editTaskForm.testItems[i];
              if(this.getSiteItemPrice(item.itemTId)==null||this.getSiteItemPrice(item.itemTId)==''){
                item.sitePrice = 0;
              }else{
                item.sitePrice = this.getSiteItemPrice(item.itemTId);
              }

              if(this.getSiteItemPriceCost(item.itemTId)==null||this.getSiteItemPriceCost(item.itemTId)==''){
                item.priceSiteCost = 0;
              }else{
                item.priceSiteCost = this.getSiteItemPriceCost(item.itemTId);
              }


            }
            this.execComputeTaskPrice();
          }else{
            this.$message({
              showClose: true,
              message: "获取场地费失败,价格计算失败1.",
              type: 'error'
            });
          }
        })
      }
    },
    getSiteItemPrice(itemTId){
      if(util.isEmpty(this.siteItemList)){
        return 0;
      }
      for(let i in this.siteItemList){
        if(this.siteItemList[i].itemTId == itemTId){
          return this.siteItemList[i].price;
        }
      }
      return 0;
    },
    getSiteItemPriceCost(itemTId){
      if(util.isEmpty(this.siteItemList)){
        return 0;
      }
      for(let i in this.siteItemList){
        if(this.siteItemList[i].itemTId == itemTId){
          // console.log(this.siteItemList[i].priceCost)
          return this.siteItemList[i].priceCost;
        }
      }
      return 0;
    },


    onGroupChange(){

      if(util.isEmpty(this.editTaskForm.groupId)){
        this.editTaskForm.groupItemIds = [];
        this.editTaskForm.groupItemTIds = [];
        this.editTaskForm.groupId = '';
        this.editTaskForm.groupName = '';
        this.editTaskForm.groupPrice = '';
        return;
      }

      getTestGroupItem({id: this.editTaskForm.groupId}).then(res=>{
          // console.log(res)
          if(res.code == 1){
            let data = res.data;
            this.testGroupItems = data;
            // console.log("2")
            // console.log(data)
            let testGroup;
            for(let i in this.groupList){
              if(this.groupList[i].id == this.editTaskForm.groupId){
                testGroup = this.groupList[i];
                break;
              }
            }
            this.editTaskForm.groupItemTIds=[];
            if(util.isNotEmpty(testGroup.itemTIds)){
              let arr = [];
              let arrStr = testGroup.itemTIds.split(",");
              for(let i in arrStr){
                if(!util.isEmpty(arrStr[i])){
                  arr.push(parseInt(arrStr[i]))
                }
              }
              // console.log(this.groupList)
              // console.log(arr)
              this.editTaskForm.groupItemTIds = arr;
              this.editTaskForm.groupId = testGroup.id;
              this.editTaskForm.groupName = testGroup.name;
              this.editTaskForm.groupPrice = testGroup.groupPrice;
              this.addItemForm.items = arr;
              this.addItemForm.tiemif = 0;
              // console.log(arr)
            }
            this.loadTestItems(()=>{
              this.taskItemsMerge();
            });
          }else{
            this.$message.error("加载信息失败")
          }
        });

    },
    GroupChange(){
      // console.log(this.editTaskForm.testItems)
      // console.log(this.addItemsGroup)
      // console.log(this.editTaskForm.priceItemPay)
      this.editTaskForm.groupItemTIds = '';
      this.editTaskForm.groupId = '';
      this.editTaskForm.groupName = '';
      this.editTaskForm.groupPrice = '';
      this.addItemForm.tiemif = 0;
      this.addItemForm.items = [];


      this.editTaskForm.testItems = [];

      this.loadTestItems(()=>{
        this.taskItemsMerge();
      });


    },


    addToTaskItems(){
      if(this.addItemForm.items && this.addItemForm.items.length > 0 ){
        this.addItemsGroup = this.addItemForm.items;
        this.taskItemsMerge();
      }

      this.showAddItemDialog = false;
    },
    getItem(itemId){
      // console.log(this.addItems)
      for(let i in this.addItems){
        if(itemId == this.addItems[i].tId || itemId == this.addItems[i].id){
          return this.addItems[i];
        }
      }
    },
    taskItemsMerge(){
      // console.log("1")
      // let param = {}



      // console.log(this.groupList)
      const testItems = this.editTaskForm.testItems;
      // console.log(this.addItemForm)
      // console.log(this.editTaskForm.testItems)
      // console.log(this.editTaskForm.testItems.length)
      for(let i in this.addItemForm.items){
        let addItem = this.getItem(this.addItemForm.items[i]);
        // console.log(addItem)
        if(util.isEmpty(addItem)){
          continue;
        }




        let inFlag = false;
        for(let j in testItems){
            if(addItem.tId == testItems[j].itemTId){
              inFlag = true;
              break;
            }
          }


          if(addItem && !inFlag){
            if(this.testGroupItems.length==0){
                // console.log("=====")
                // console.log(this.testGroupItems)
                // console.log("=====")
                let ii = {
                  id: 0,
                  itemId: addItem.id,
                  itemTId: addItem.tId,
                  itemName: addItem.itemName,
                  serialNumber: addItem.serialNumber,
                  itemPrice: addItem.price,
                  sitePrice: 0, // 场地费
                  num: 1,
                  rebate: this.editForm.rebate,
                  price: 0,
                  siteRebate: this.editForm.siteRebate,
                  priceSite:0,
                  costRebate: this.editTaskForm.costRebate,
                  priceCost: 0,
                  costSiteRebate: 100,
                  priceSiteCost: 0,
                  carIds:[],
                  inGroup: 0,
                }
                testItems.push(ii);
              }else if(this.addItemForm.tiemif==1){
                let ii = {
                id: 0,
                itemId: addItem.id,
                itemTId: addItem.tId,
                itemName: addItem.itemName,
                serialNumber: addItem.serialNumber,
                itemPrice: addItem.price,
                sitePrice: 0, // 场地费

                num: 1,
                rebate: this.editForm.rebate,
                price: 0,
                siteRebate: this.editForm.siteRebate,
                priceSite:0,
                costRebate: this.editTaskForm.costRebate,
                priceCost: 0,
                costSiteRebate: 100,
                priceSiteCost: 0,
                carIds:[],
                inGroup: 0,
                }
                testItems.push(ii);

              }else{
                let ii = {
                id: 0,
                itemId: addItem.id,
                itemTId: addItem.tId,
                itemName: addItem.itemName,
                serialNumber: addItem.serialNumber,
                itemPrice: addItem.price,
                sitePrice: 0, // 场地费

                num: this.testGroupItems[i].num,
                rebate: this.editForm.rebate,
                price: 0,
                siteRebate: this.editForm.siteRebate,
                priceSite:0,
                costRebate: this.editTaskForm.costRebate,
                priceCost: 0,
                costSiteRebate: 100,
                priceSiteCost: 0,
                carIds:[],
                inGroup: 0,
                }
                testItems.push(ii);
              }
            }
        }
      this.resetInGroup();

    },
    resetInGroup(){
      let groupItemIds = [];
      for(let i in this.editTaskForm.testItems){
        let item = this.editTaskForm.testItems[i];
        if((!util.isEmpty(this.editTaskForm.groupItemTIds))
          && this.editTaskForm.groupItemTIds.indexOf(item.itemTId) != -1
        ){
          item.inGroup = 1;
          groupItemIds.push(item.itemId);
        }else{
          item.inGroup = 0;
        }
      }

      if(!util.isEmpty(groupItemIds)){
        this.editTaskForm.groupItemIds = groupItemIds.join();
      }

      this.computeTaskPrice()

    },
    loadTestItems(fn){
      this.addItems = [];

      const loadingDiv = util.showLoading("加载中...")
      const param = {
        carTypeId: this.editTaskForm.carTypeId,
        productTypeId1: this.editTaskForm.productTypeId1,
        productTypeId2: this.editTaskForm.productTypeId2,
      }
      getTestGroupItem({id: this.editTaskForm.groupId}).then(res=>{
        // console.log("1")
          // console.log(res)
          if(res.code == 1){
            let data = res.data;
            this.testGroupItems = data;
            // console.log("2")

          }else{
            this.$message.error("加载信息失败")
          }
        });

      getTestItemList2(param).then(res=>{
        loadingDiv.close();
        if(res.code == 1){
          //this.addItems = res.data;
          let arr = [];
          let data = res.data;
          // console.log(data)

          for(let i in data){
            let item = data[i];
            item['label'] = item.serialNumber + "-" + item.itemName;
            arr.push(item)
          }

          this.addItems = arr;


          if(fn){
            fn();
          }
        }else{
          this.$message({
            showClose: true,
            message: "加载检测项目失败",
            type: 'error'
          });
        }
      }).catch(err=>{
        loadingDiv.close();
      });
    },
    showChoseItemDialog(){
      if(util.isEmpty(this.editTaskForm.carTypeId)){
        this.$message({
          showClose: true,
          message: "请先选择车型类别",
          type: 'error'
        });
        return;
      }
      if(util.isEmpty(this.editTaskForm.productTypeId1)
        || util.isEmpty(this.editTaskForm.productTypeId2)){
        this.$message({
          showClose: true,
          message: "请先选择申报类型",
          type: 'error'
        });
        return;
      }

      if(util.isEmpty(this.editTaskForm.orgId)){
        this.$message({
          showClose: true,
          message: "请先选择检测机构",
          type: 'error'
        });
        return;
      }

      this.addItemForm.items=[];
      this.loadTestItems();

      this.addItemForm.tiemif = 1;
      this.showAddItemDialog = true;

    },
    onCarTypeChange(){
      this.groupList = [];
      this.editTaskForm.groupId = '';
      this.editTaskForm.testItems = [];
      for(let i in this.carTypeList){
        if(this.carTypeList[i].id == this.editTaskForm.carTypeId){
          this.editTaskForm.carTypeName = this.carTypeList[i].name;
          break;
        }
      }
      this.getGroupList();
      // this.editTaskForm.carTypeId=this.editForm.carTypeId;
      // console.log("1")
      // console.log(this.editTaskForm.carTypeId)
    },
    clear(){
      for(let key in this.searchForm){
        this.searchForm[key]  = ''
      }
      for(let key in this.date){
        this.date[key]  = ''
      }
      this.searchForm.userTypeIdList = [1,2,3,4,5,6];
      this.searchForm.orderStatus = 0;
      this.getDataList(this.currentPage);
    },
    onProductTypeChange(){
      this.groupList = [];
      this.editTaskForm.groupId = '';
      this.editTaskForm.testItems = [];
      this.editTaskForm.productTypeId1 = this.editTaskForm.productTypeIds[0];
      this.editTaskForm.productTypeId2 = this.editTaskForm.productTypeIds[1];
      this.editForm.productTypeId1 = this.editForm.productTypeIds[0];
      this.editForm.productTypeId2 = this.editForm.productTypeIds[1];

      for(let i in this.testProductTypeList){
        if(this.testProductTypeList[i].id == this.editTaskForm.productTypeId1){
          this.editTaskForm.productTypeName1 = this.testProductTypeList[i].name;
          let list = this.testProductTypeList[i].children;
          for(let j in list){
            if(list[j].id == this.editTaskForm.productTypeId2){
              this.editTaskForm.productTypeName2 = list[j].name;
              break;
            }
          }
          break;
        }
      }
      this.getGroupList();

      let param = {
        productTypeIds: this.editForm.productTypeId1,
      }

      getUser(param).then(res => {
        if(res.code == 1) {
          this.userList = res.data;
          // console.log(this.userList)
        }
      }).catch(res => {

      });






    },
    carVin(){
      for(var i=0;i<this.carVinList.length;i++){
        if(this.carVinList[i].id==this.editTaskForm.carId){
          this.editTaskForm.color = this.carVinList[i].color
          this.editTaskForm.name = this.carVinList[i].name
          this.editTaskForm.model = this.carVinList[i].model
          this.editTaskForm.vin = this.carVinList[i].vin
          this.editTaskForm.prDate = this.carVinList[i].prDate
        }

      }
    },
    getGroupList(){
      if(util.isEmpty(this.editTaskForm.productTypeId1)
      || util.isEmpty(this.editTaskForm.productTypeId2)
      || util.isEmpty(this.editTaskForm.carTypeId)){
        this.groupList = [];
        return;
      }

      let param = {
        carTypeId: this.editTaskForm.carTypeId,
        productTypeId1: this.editTaskForm.productTypeId1,
        productTypeId2: this.editTaskForm.productTypeId2,
        carEnterpriseId: this.editForm.carEnterpriseId,
      }

      getAllTestGroupListByParam(param).then(res=>{
        if(res.code == 1){
          this.groupList = res.data;

        }
      });
    },
    addOrderTask(){
      if(util.isEmpty(this.editTaskForm.carTypeId)){
        this.$message.error('请选择车型类别');
        return;
      }
      if(util.isEmpty(this.editTaskForm.productTypeId1) || util.isEmpty(this.editTaskForm.productTypeId2)){
        this.$message.error('请选择申报类型');
        return;
      }
      if(util.isEmpty(this.editTaskForm.testItems)){
        this.$message.error('请选择检测项目');
        return;
      }
      if(util.isEmpty(this.editTaskForm.siteId)){
        this.$message.error('请选择检测场地');
        return;
      }

      if(this.editTaskForm.carPeople==null||this.editTaskForm.carPeople==''){
        this.editTaskForm.carPeople = [];

      }



      //公告：ABCDEFGHIK 1
      //达标：ABCDEFGHJKLMN 2
      //CCC：ABCDEFKG 3
      //环保：ABCDEFK 4
      //其他：ABCDEFKO 19
      // switch(this.editForm.productTypeId1){
      //   case 1:
      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.g)
      //       || util.isEmpty(this.editForm.h)
      //       || util.isEmpty(this.editForm.i)
      //       || util.isEmpty(this.editForm.k)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 2:
      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.g)
      //       || util.isEmpty(this.editForm.h)
      //       || util.isEmpty(this.editForm.j)
      //       || util.isEmpty(this.editForm.k)
      //       || util.isEmpty(this.editForm.l)
      //       || util.isEmpty(this.editForm.m)
      //       || util.isEmpty(this.editForm.n)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 3:

      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.k)
      //       || util.isEmpty(this.editForm.g)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 4:

      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.k)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 19:
      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.k)
      //       || util.isEmpty(this.editForm.o)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      // }


      if(this.editTaskIndex == -1){
        this.editForm.testTasks.push(JSON.parse(JSON.stringify(this.editTaskForm)))
      }else{
        this.editForm.testTasks[this.editTaskIndex] = JSON.parse(JSON.stringify(this.editTaskForm));
      }
      this.computeOrderPrice()

      this.showEditTaskDialog = false;
    },
    showAddOrderTask(){
      this.loadCarList();

      if(util.isEmpty(this.editForm.carEnterpriseId)){
        this.$message({
          showClose: true,
          message: "请选择车企",
          type: 'error'
        });
        return;
      }
      if(util.isEmpty(this.editForm.carTypeId)){
        this.$message({
          showClose: true,
          message: "请选择车型类别",
          type: 'error'
        });
        return;
      }
      if(util.isEmpty(this.editForm.productTypeIds)){
        this.$message({
          showClose: true,
          message: "请选择申报类型",
          type: 'error'
        });
        return;
      }
      if(util.isEmpty(this.editForm.name)){
        this.$message({
          showClose: true,
          message: "请填写产品名称",
          type: 'error'
        });
        return;
      }
      if(util.isEmpty(this.editForm.model)){
        this.$message({
          showClose: true,
          message: "请填写产品型号",
          type: 'error'
        });
        return;
      }


      for(let key in this.editTaskForm){
        this.editTaskForm[key] = '';
      }

      this.editTaskForm.id=0;
      this.editTaskForm.testItems = [];
      this.editTaskForm.productTypeIds=[];
      this.editTaskForm.groupItemTIds=[];
      this.editTaskIndex = -1;
      this.addItemsGroup= [];


      this.showEditTaskDialog = true;



      this.editTaskForm.carTypeId=this.editForm.carTypeId;
      this.editTaskForm.productTypeIds=this.editForm.productTypeIds;
      this.editTaskForm.productTypeId1 = this.editTaskForm.productTypeIds[0];
      this.editTaskForm.productTypeId2 = this.editTaskForm.productTypeIds[1];
      this.getGroupList();
      this.editForm.productTypeId1 = this.editTaskForm.productTypeIds[0];
      this.editForm.productTypeId2 = this.editTaskForm.productTypeIds[1];
      this.editTaskForm.name=this.editForm.name;
      this.editTaskForm.model=this.editForm.model;

      this.onCarEntChange();


      this.editTaskForm.suggestTime=this.editForm.suggestTime;
      this.editTaskForm.importance=this.editForm.importance;
      this.editTaskForm.cause=this.editForm.cause;

      this.groupList = [];
      this.editTaskForm.groupId = '';
      this.editTaskForm.testItems = [];
      for(let i in this.carTypeList){
        if(this.carTypeList[i].id == this.editTaskForm.carTypeId){
          this.editTaskForm.carTypeName = this.carTypeList[i].name;
          break;
        }
      }

      this.groupList = [];
      this.editTaskForm.groupId = '';
      this.editTaskForm.testItems = [];
      this.editTaskForm.productTypeId1 = this.editTaskForm.productTypeIds[0];
      this.editTaskForm.productTypeId2 = this.editTaskForm.productTypeIds[1];

      for(let i in this.testProductTypeList){
        if(this.testProductTypeList[i].id == this.editTaskForm.productTypeId1){
          this.editTaskForm.productTypeName1 = this.testProductTypeList[i].name;
          let list = this.testProductTypeList[i].children;
          for(let j in list){
            if(list[j].id == this.editTaskForm.productTypeId2){
              this.editTaskForm.productTypeName2 = list[j].name;
              break;
            }
          }
          break;
        }
      }

    },
    onCarEntChange(){
      for(let i in this.carEntList){
        if(this.carEntList[i].id == this.editForm.carEnterpriseId){

          if(this.editForm.productTypeId1==1){
            this.editForm.rebate=this.carEntList[i].rebate;
          }
          if(this.editForm.productTypeId1==2){
            this.editForm.rebate=this.carEntList[i].rebate1;
          }
          if(this.editForm.productTypeId1==3){
            this.editForm.rebate=this.carEntList[i].rebate2;
          }
          if(this.editForm.productTypeId1==4){
            this.editForm.rebate=this.carEntList[i].rebate3;
          }
          if(this.editForm.productTypeId1==19){
            this.editForm.rebate=this.carEntList[i].rebate4;
          }

          this.editForm.siteRebate=this.carEntList[i].siteRebate;
          this.editForm.brand = this.carEntList[i].brand
          break;
        }
      }
      this.loadCarList();

    },
    onOrgCost(){
      // console.log("1")

      for(let i in this.orgList){
        if(this.orgList[i].id == this.editTaskForm.orgId){
          // console.log(this.orgList)
          // console.log(this.editForm.productTypeId1)
          if(this.editForm.productTypeId1==1){
            this.editTaskForm.costRebate=this.orgList[i].rebate;
          }
          if(this.editForm.productTypeId1==2){
            this.editTaskForm.costRebate=this.orgList[i].rebate1;
          }
          if(this.editForm.productTypeId1==3){
            this.editTaskForm.costRebate=this.orgList[i].rebate2;
          }
          if(this.editForm.productTypeId1==4){
            this.editTaskForm.costRebate=this.orgList[i].rebate3;
          }
          if(this.editForm.productTypeId1==19){
            this.editTaskForm.costRebate=this.orgList[i].rebate4;
          }
          break;
        }
      }
      // this.execComputeTaskPrice();
      // this.taskItemsMerge();
      // this.editTaskForm.testItems=[];
    },
    showAddDialogForm() {
      if(this.$refs.editForm){
        this.$refs.editForm.clearValidate();
      }

      for(let key in this.editForm){
        this.editForm[key] = '';
      }

      this.editForm.id = 0;
      this.editForm.testTasks = [];
      this.editForm.priceCost = 0;
      this.editForm.price = 0;
      this.editForm.payPrice = 0;
      this.editForm.payPriceStatus = 0;
      this.editForm.rebate = 100;
      this.editForm.siteRebate = 100;

      this.editFormVisible = true;
    },
    init(){
      getUserRole().then(res => {
        if(res.code == 0) {
          this.$message({
            showClose: true,
            message: res.msg,
            type: 'error'
          });
        }else if(res.code == 1) {
          let data = res.data;
          this.userRole = data.userRole
          // console.log(this.userRole)
          if(this.userRole==7){
            getUserTestCarEnterpriseList().then(res => {
              if(res.code == 1) {
                this.carEntList = res.data;
                // console.log(this.carEntList)
              }
            }).catch(res => {

            })
          }else{
            getAllTestCarEnterpriseList().then(res => {
              if(res.code == 1) {
                this.carEntList = res.data;
                // console.log(this.carEntList)
              }
            }).catch(res => {

            })
          }
        }
        loadingDiv.close();
      }).catch(res => {

      });



      this.getAllCarTypeList();

      // 获取所有检测产品类别
      getAllTestProductTypeList().then(res => {
        if(res.code == 1) {
          this.testProductTypeList = res.data;
        }
      }).catch(res => {

      });

      // 获取所有检测场地
      getAllTestSiteList().then(res => {
        if(res.code == 1) {
          this.testSiteList = res.data;
        }
      }).catch(res => {

      });
      // 获取所有业务经理
      getAllTestoperationManagerList().then(res => {
        if(res.code == 1) {
          this.customerNameList = res.data;
        }
      }).catch(res => {

      });

      //获取所有用户列表
      getAllUserList().then(res => {
        if(res.code == 1) {
          this.userList = res.data;
          // console.log(this.userList)
        }
      }).catch(res => {

      });

      getAllTestOrgList().then(res => {
        if(res.code == 1) {
          this.orgList = res.data;

        }
      }).catch(res => {

      });

    },
    getAllCarTypeList(){
      getAllCarTypeList().then(res=>{
        if(res.code == 1) {
          this.carTypeList = res.data;
        }
      }).catch(res => {

      })
    },
    refreshCarEntList(){

      if(this.userRole==7){
        getUserTestCarEnterpriseList().then(res => {
          if(res.code == 1) {
            this.carEntList = res.data;
            // console.log(this.carEntList)
          }
        }).catch(res => {

        })
      }else{
        getAllTestCarEnterpriseList().then(res => {
          if(res.code == 1) {
            this.carEntList = res.data;
            // console.log(this.carEntList)
          }
        }).catch(res => {

        })
      }
    },
    handlerOpenPage(t){

      let item = {};

      switch(t){
        case 1: // 跳转到车型管理
          item = {
            componentName:"testCarEnterpriseManage",
            icon:"",
            path:"/base/test_car_enterprise_manage",
            title: "车型类别管理",
          };
          break;
        case 2: // 跳转到车辆管理
          item = {
            componentName:"testCarManage",
            icon:"",
            path:"/test_car/test_car_manage",
            title: "车辆管理",
          };
          break;
      }

      this.editFormVisible=false;
      this.nextShow = true;
      this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}});

      // window.open("/#/base/car_type_manage");
    },


    fmtDate(d2, fmt) { // yyyy-MM-dd hh:mm:ss
      if (util.isEmpty(d2) || d2 <= 0){
        return "";
      }
      return  util.fmtDate(new Date(d2), fmt);
    },

    nameModel(name,model){
      if(name==null||model==null||name==''||model==''){
        return "";
      }else{
        return  name+'('+model+')'
      }
    },

    serialNumber(data,data1,itemList){
      if(util.isEmpty(data)){
        return itemList;
      }
      if(!util.isEmpty(data)&&!util.isEmpty(data1)){
      let arr= data1.split(",");
      let arrTemps = data.split(",");


      let arrTemp = data.split(",");

      let sArr = [];
      for(let i in arrTemp){
          let num = parseInt(arr[i]);
          // console.log(num)
          for(let j=0;j<num;j++){
            sArr.push(arrTemp[i]);
          }
      }

      // console.log("==============================")
      // console.log(sArr)
      // console.log("==============================")

      var serialNumber='';
      var arrs = sArr;
      var res = []; //
      arrs.sort();
      for (var i = 0; i < arrs.length;) {
          var count = 0;
          for (var j = i; j < arrs.length; j++) {
              if (arrs[i] == arrs[j]) {
                  count++;
              }
          }
          res.push([arrs[i], count]);
          i += count;
      }
      //_res 二维数维中保存了 值和值的重复数
      var newArr = [];
      for (var i = 0; i < res.length; i++) {
          // console.log(_res[i][0] + "重复次数:" + _res[i][1]);
          newArr.push(res[i][0] + '*' + res[i][1]);
      }
      // console.log(arrTemps);
      // console.log(arr);
      serialNumber = newArr.join(",");
      return serialNumber;
      }

    },

    significance(data){
      if(data==1){
        return "是";
      }else{
        return "否";
      }
    },

    submitForm() {


      if(util.isEmpty(this.editForm.testTasks)){
        this.$message.error('请选增加检测任务');
        return;
      }

      //公告：ABCDEFGHIK 1
      //达标：ABCDEFGHJKLMN 2
      //CCC：ABCDEFKG 3
      //环保：ABCDEFK 4
      //其他：ABCDEFKO 19
      // switch(this.editForm.productTypeId1){
      //   case 1:
      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.g)
      //       || util.isEmpty(this.editForm.h)
      //       || util.isEmpty(this.editForm.i)
      //       || util.isEmpty(this.editForm.k)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 2:
      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.g)
      //       || util.isEmpty(this.editForm.h)
      //       || util.isEmpty(this.editForm.j)
      //       || util.isEmpty(this.editForm.k)
      //       || util.isEmpty(this.editForm.l)
      //       || util.isEmpty(this.editForm.m)
      //       || util.isEmpty(this.editForm.n)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 3:

      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.k)
      //       || util.isEmpty(this.editForm.g)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 4:

      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.k)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      //   case 19:
      //     if(util.isEmpty(this.editForm.a)
      //       || util.isEmpty(this.editForm.b)
      //       || util.isEmpty(this.editForm.c)
      //       || util.isEmpty(this.editForm.d)
      //       || util.isEmpty(this.editForm.e)
      //       || util.isEmpty(this.editForm.f)
      //       || util.isEmpty(this.editForm.k)
      //       || util.isEmpty(this.editForm.o)){
      //       this.$message.error('请选择检测工程师');
      //       return;
      //     }
      //     break;
      // }


      //this.editForm.next = 0;
      if(this.editForm.id == 0){
        this.saveOrNext();
      }else{
        this.updateOrder();
      }



    },
    updateOrder(){
      const loadingDiv = util.showLoading("保存中")
      this.loading = true;
      updateOrder(this.editForm).then(res => {
        if(res.code == 0) {
          this.$alert(res.msg, "保存失败", {dangerouslyUseHTMLString:true,type:'warning'})
        }else if(res.code == 1) {
          this.$alert(res.msg, "保存成功", {dangerouslyUseHTMLString:true,type:'success'})
            .then(()=> {
              this.editFormVisible=false;
              this.getDataList(this.currentPage)
            })
        }
        this.loading = false;
        loadingDiv.close();
      }).catch(res => {
        this.loading = false;
        loadingDiv.close();
      })
    },
    submitFormNext() {
      this.editForm.next = 1;
      this.saveOrNext();
    },

    saveOrNext(){

      this.$refs.editForm.validate(valid => {
        if(valid) {
          this.loading = true;
          let loadingText = "保存中...";
          if(this.editForm.next == 1){
            loadingText = "下发中...";
          }
          const loadingDiv = util.showLoading(loadingText)
          saveOrNextTestOrder(this.editForm).then(res => {
            let title = "保存"
            if(this.editForm.next == 1){
              title = "下发"
            }
            if(res.code == 0) {
              this.$alert(res.msg, title+"失败", {dangerouslyUseHTMLString:true,type:'warning'})
            }else if(res.code == 1) {
              this.$alert(res.msg, title+"成功", {dangerouslyUseHTMLString:true,type:'success'})
                .then(()=> {
                  this.editFormVisible=false;
                  this.getDataList(this.currentPage)
                })
            }
            this.loading = false;
            loadingDiv.close();
          }).catch(res => {
            this.loading = false;
            loadingDiv.close();
          })
        }
      });
    },

    handleDelete(index, row) {
      let loadingDiv;
      this.$confirm("是否确认删除?","删除确认").then(res=>{
        if(res='confirm'){
          loadingDiv = util.showLoading("删除中...")
          return deleteTestOrder({tOrderId: row.tOrderId})
        }
      }).then(res => {
        loadingDiv.close();
        if(res.code == 0) {
          this.$alert(res.msg, "删除失败", {dangerouslyUseHTMLString:true,type:'warning'})
        }else if(res.code == 1) {
          this.$alert(res.msg, "删除成功", {dangerouslyUseHTMLString:true,type:'success'})
            .then(res=>{
              this.editFormVisible=false;
              this.getDataList(this.currentPage)
            })
        }
      }).catch(res=>{
        if (loadingDiv){
          loadingDiv.close();
        }
      })
    },
    getDataList(pageNum){
      const loadingDiv = util.showLoading()
      getUserRole().then(res => {
        if(res.code == 0) {
          this.$message({
            showClose: true,
            message: res.msg,
            type: 'error'
          });
        }else if(res.code == 1) {
          let data = res.data;
          this.userRole = data.userRole
          // console.log(this.userRole)

        }
        loadingDiv.close();
      }).catch(res => {
        loadingDiv.close();
      });


      getTestOrderList({
        pageSize: this.pageSize,
        pageNum: pageNum,
        orderStatus: this.searchForm.orderStatus,
        carEnterpriseId: this.searchForm.carEnterpriseId,
        carTypeId: this.searchForm.carTypeId,
        productTypeIds: this.searchForm.productTypeIds,
        customerName: this.searchForm.customerName,

      }).then(res => {
        if(res.code == 0) {
          this.$message({
            showClose: true,
            message: res.msg,
            type: 'error'
          });
        }else if(res.code == 1) {
          let data = res.data;
          this.currentPage = pageNum;
          this.total = data.total;
          this.tableData = data.dataList;
        }
        loadingDiv.close();
      }).catch(res => {
        loadingDiv.close();
      });



    },
    search() {
      this.getDataList(this.currentPage)
    },

    handleSizeChange(pageSize) {
            this.pageSize = pageSize;
            this.getDataList(1)
          },
    handleCurrentChange(pageNum) {
            this.getDataList(pageNum);
          },
    handlePriceOtherManage(index, row){
      let item = {
        componentName:"priceOtherManage",
        icon:"",
        path:"/task/price_other_manage/"+row.tOrderId,
        title: "其他费用管理",
      };

      this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}})
    },

    handleOrderTask(index, row){
      // let item = {
      //   componentName:"testOrderTaskManage",
      //   icon:"",
      //   path:"/task/test_order_task_manage/"+row.tOrderId,
      //   title: "任务下发",
      // };

      // this.$store.commit("openTab",{item:item, router: (path)=>{this.$router.replace(path)}})

    },
  }
}
</script>

<style scoped lang="scss">
  // @import "~@/common/styles/element-variables.scss";
  .search-box {
    background-color: #FFFFFF;
    min-height: 36px;
    line-height: 36px;
    padding-top: 2px;
    padding-bottom: 6px;
    .el-form-item {
      margin-bottom: 0px !important;
    }
    .el-form--inline {
      display: inline-block;
    }
  }
  .pagination-box {
    text-align: left;
    margin-top: 10px;
  }
  .test-item-table{
    width: 100%;
    border-collapse: collapse;

    th, td {
      width: 7%;
      text-align: center;
      border: 1px solid #CCC;
    }
    th {
      background-color: #EDF2FC;
    }
  }
  .chose-role{
    display: inline-block;
    margin-left: 20px;
    margin-bottom: 20px;
  }
</style>
<style lang="scss">
  .el-dialog__header {

  }
  .el-dialog__body {
    padding-top: 10px;
    padding-bottom: 0px;
  }
  .el-dialog__footer {
    padding-top: 0px;
  }
</style>
